﻿using System;
using System.Data;
using System.Collections.Generic;

namespace BLL.Procurement
{
    public class T_PUB_WAREHOUSING
    {
        private readonly DALL.Procurement.T_PUB_WAREHOUSING dal = new DALL.Procurement.T_PUB_WAREHOUSING();
        public T_PUB_WAREHOUSING()
        { }


        /// <summary>
        /// 获取采购入库主题
        /// </summary>
        /// <param name="branch_id"></param>
        /// <returns></returns>
        public DataSet GetPurchaseInApplyTitel(int branch_id)
        {
            return dal.GetPurchaseInApplyTitel(branch_id);
        }

        public DataSet GetPurchaseInApplyTitel()
        {
            return dal.GetPurchaseInApplyTitel();
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetApplyList(int uid, int bid, string titel, DateTime begintime, DateTime endtime)
        {
            string strWhere = "";
            if (uid != -1)
            {
                strWhere += string.Format(" and APPLICANT = {0}", uid);
            }
            if (bid != -1)
            {
                strWhere += string.Format(" and a.BRANCH_ID = {0}", bid);
            }
            if (!string.IsNullOrEmpty(titel))
            {
                strWhere += string.Format(" and TITEL like '%{0}%'", titel);
            }
            if (!string.IsNullOrEmpty(begintime.ToString()))
            {
                strWhere += string.Format(" and TIME >= '{0}' ", begintime);
            }
            if (!string.IsNullOrEmpty(endtime.ToString()))
            {
                strWhere += string.Format(" and TIME <= '{0}' ", endtime);
            }
            DataSet ds = dal.GetApplyList(strWhere);
            return ds;
        }

        #region  Method


        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(Model.Procurement.T_PUB_WAREHOUSING model)
        {
            return dal.Add(model);
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Model.Procurement.T_PUB_WAREHOUSING model)
        {
            return dal.Update(model);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool Delete(string ID)
        {

            return dal.Delete(ID);
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.Procurement.T_PUB_WAREHOUSING GetModel(string ID)
        {

            return dal.GetModel(ID);
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            return dal.GetList(strWhere);
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<Model.Procurement.T_PUB_WAREHOUSING> GetModelList(string strWhere)
        {
            return dal.GetListArray(strWhere);
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetAllList()
        {
            return GetList("");
        }
        #endregion
    }
}
